using System.ComponentModel;
using System.IO;

namespace RequestEchoNest.ViewModel
{
    public class SettingsTabViewModel:INotifyPropertyChanged 
    {
        public string DeveloperKey
        {
            get
            {
                var developerKey = Settings.Default.DeveloperKey;
                if (string.IsNullOrEmpty(developerKey))
                {
                    if (File.Exists(Constants.DeveloperKeyFileName))
                    {
                        developerKey = File.ReadAllText(Constants.DeveloperKeyFileName);
                        Settings.Default.DeveloperKey = developerKey;
                    }
                }
                return developerKey;
            }
            set
            {
                Settings.Default.DeveloperKey = value;
                PropertyChanged(this,new PropertyChangedEventArgs("DeveloperKey"));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged = delegate{};
    }
}